python用函数怎么判断大小写

您所在的位置:网站首页 python 判断数组长度 python用函数怎么判断大小写

python用函数怎么判断大小写

2022-10-09 03:48| 来源: 网络整理| 查看: 265

python用函数怎么判断大小写 发布时间:2020年11月11日 22:21:43 来源:环球青藤 点击量:161

【摘要】Python提供了isupper(),islower(),istitle()方法用来判断字符串的大小写, 具体实例如下:例如:(推荐学习:Python视频教程) >>> str_

Python提供了isupper(),islower(),istitle()方法用来判断字符串的大小写, 具体实例如下:

例如:(推荐学习:Python视频教程)

>>> str_1 = "HELLO PYTHON" # 全大写 >>> str_2 = "Hello PYTHON" # 大小写混合 >>> str_3 = "Hello Python" # 单词首字母大写 >>> str_4 = "hello python" # 全小写

isupper() 判断是否全是大写

>>> str_1.isupper() True >>> str_2.isupper() False >>> str_3.isupper() False >>> str_4.isupper() False

islower()判断是否全是小写

>>> str_1.islower() False >>> str_2.islower() False >>> str_3.islower() False >>> str_4.islower() True

istitle()判断首字母是否大写, 其余的是否小写

>>> str_1.istitle() False >>> str_2.istitle() False >>> str_3.istitle() True >>> str_4.istitle() False

更多Python相关技术文章,请访问Python教程栏目进行学习!

以上就是小编分享的关于python用函数怎么判断大小写的详细内容希望对大家有所帮助,更多有关python教程请关注环球青藤其它相关文章!

分享到: 编辑:wangmin

上一篇:怎么查看python版本? 下一篇:Python怎么把三位数拆开


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3